package gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import logic.Facade;
import logic.ToGuiFacade;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class pnlLogin extends javax.swing.JPanel {

	/**
	 *
	 */
	private static final long serialVersionUID = 1L;
	private static JLabel alertLabel;
	private JLabel picLabel;
	private JTextArea passwordTextArea;
	private JTextField nameTextField;
	private JTextArea loginNameTextArea;
	private JPasswordField passwordField;
	private JButton loginButton;
	private JLabel oldUserLabel;
	private JButton newUserButton;
	private JLabel newUserLabel;
	private JLabel headlineLabel;
	/**
	* Auto-generated main method to display this
	* JPanel inside a new JFrame.
	*/
	public static void main(String[] args) {
	}

	public pnlLogin() {
		super();
		initGUI();
	}

	private void initGUI() {
		try {
			setLayout(null);
			setBackground(new java.awt.Color(255,128,0));
			{
				picLabel = new JLabel();
				add(picLabel);
				picLabel.setIcon(new ImageIcon(getClass().getClassLoader().getResource("documentation/Secret4PlusDog.jpg")));
				picLabel.setBounds(538, 48, 220, 407);
			}
			{
				headlineLabel = new JLabel();
				add(headlineLabel);
				headlineLabel.setText("SECRET 4 PLUS DOG");
				headlineLabel.setBounds(19, 93, 419, 80);
				headlineLabel.setFont(new java.awt.Font("Tahoma",3,36));
				headlineLabel.setForeground(new java.awt.Color(0,128,192));
			}
			{
				newUserLabel = new JLabel();
				add(newUserLabel);
				newUserLabel.setText("If you are new in our system push this button");
				newUserLabel.setBounds(43, 197, 338, 24);
				newUserLabel.setFont(new java.awt.Font("Arial",1,14));
			}
			{
				newUserButton = new JButton();
				add(newUserButton);
				newUserButton.setText("I am a new user");
				newUserButton.setBounds(126, 233, 140, 21);
				newUserButton.addMouseListener(new MouseAdapter() {
					public void mouseClicked(MouseEvent evt) {
						ToGuiFacade.getInstance().changeScreen(new pnlUserRegistration());
					}
				});
			}
			{
				oldUserLabel = new JLabel();
				add(oldUserLabel);
				oldUserLabel.setText("If you have been here before push this button");
				oldUserLabel.setBounds(43, 283, 345, 14);
				oldUserLabel.setFont(new java.awt.Font("Arial",1,14));
			}
			{
				loginButton = new JButton();
				add(loginButton);
				loginButton.setText("Enter");
				loginButton.setBounds(247, 396, 72, 26);
				loginButton.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){
						Facade.getInstance().login(nameTextField.getText(),String.copyValueOf(passwordField.getPassword()));
					}
				});			
			}
			{
				passwordTextArea = new JTextArea();
				add(passwordTextArea);
				passwordTextArea.setFont(new java.awt.Font("Arial",1,12));
				passwordTextArea.setText("Password:");
				passwordTextArea.setEditable(false);
				passwordTextArea.setOpaque(false);
				passwordTextArea.setBounds(43, 361, 107, 24);
				passwordTextArea.setFocusable(false);
			}
			{
				passwordField = new JPasswordField();
				add(passwordField);
				passwordField.setBounds(156, 361, 163, 24);
			}
			{
				nameTextField = new JTextField();
				add(nameTextField);
				nameTextField.setBounds(157, 322, 162, 24);
			}
			{
				loginNameTextArea = new JTextArea();
				add(loginNameTextArea);
				loginNameTextArea.setFont(new java.awt.Font("Arial",1,12));
				loginNameTextArea.setText("User name:");
				loginNameTextArea.setEditable(false);
				loginNameTextArea.setOpaque(false);
				loginNameTextArea.setBounds(43, 322, 132, 28);
			}
			{
				alertLabel = new JLabel();
				this.add(alertLabel);
				alertLabel.setText("nothing");
				alertLabel.setVisible(false);
				alertLabel.setBounds(89, 447, 400, 17);
			}
			this.setSize(793, 549);
			this.setPreferredSize(new java.awt.Dimension(793, 549));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}


	public static void setAlertLabel(String string) {
		alertLabel.setText(string);
		alertLabel.setVisible(true);
		
	}


}
